<?php
require_once(CONST_LIBARY.'PHPUpload/class.upload.php');

class enviarUpload
{

	private $strPasta;
	private $frmCampo;
	private $strNomeArquivo;
	private $objUpload;
	
	
    public function __construct( $strPasta, $frmCampo )
    {
		$this->strPasta = $strPasta;
		$this->frmCampo = $frmCampo;
		$this->strNomeArquivo = $_FILES[$this->frmCampo]['name'];
							
    }	
	

    public function enviarArquivo()
    {
		$this->objUpload = new Upload($_FILES[$this->frmCampo]);
		
		if( $this->strNomeArquivo != '' ){
				$this->objUpload->file_new_name_body = gmmktime().'-'.$this->strNomeArquivo;
		}
		
		$this->objUpload->Process( CONST_STORAGE . '/' . $this->strPasta );
		
		if ($this->objUpload->uploaded) {
			
			return $nome_da_imagem = $this->objUpload->file_dst_name;
			
		}else{
			return 'ERROR';
		}
			
    }		
    
			
}			
?>